package com.b2b2c.store.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.b2b2c.store.sharding.entity.DbGoods;
import com.b2b2c.store.sharding.logic.GoodsLogic;
import com.b2b2c.store.sharding.mapper.DbGoodsMapper;
import com.b2b2c.store.sharding.service.IGoodsService;
import com.b2b2c.until.AjaxMap;
import com.b2b2c.until.IsLogin;
import com.b2b2c.until.PageResultList;


@RestController
public class GoodsController {

	@Autowired
	private HttpServletRequest req;
	
	@Autowired
	private DbGoodsMapper goodsMapper;
	

	@RequestMapping("/Goods/topGoodsList")
	public Map<String, ?> goodsList() {
		
		
		if (!IsLogin.checkLogin(this.req)) {
			
			return AjaxMap.getInstance("未登录").notLoggedIn();
		}
		
		IGoodsService<DbGoods> goodsService = new GoodsLogic(req);
		
		goodsService.setMapper(goodsMapper);
		
		PageResultList<DbGoods> goodsData = goodsService.getDataByPage(goodsMapper);
		
		
		return AjaxMap.getInstance(goodsData).getAjaxResultByMap();
	}
	
	
//	//商品添加
//	
//	@RequestMapping("/Goods/addGoodsInfo")
//	public Map<String, ?> addGoodsInfo()
//	{
//		
//	}
}
